$(function () {
    /* 发送ajax 获取借款人信息 */
    $.ajax({
        url: 'http://139.9.177.51:3333/p2p/getborrowinfo',
        type: 'get',
        data: {
            borrowid: localStorage.getItem('borrowid')
        },
        success: function (data) {
            // console.log(data.data)
            $('#info').html(JSON.stringify(data.data))
            console.log( $('#info').html(JSON.stringify(data.data)));
        }
    })


    /* 发送投资的ajax */
    $('#investBtn').on('click', function () {
        $.ajax({
            url: 'http://139.9.177.51:3333/p2p/invest',
            type: 'post',
            data: {
                userid: JSON.parse(localStorage.getItem('yhm')).id,
                borrowid: localStorage.getItem('borrowid'),
                chargemoney: $('#chargemoney').val()
            },
            success: function (data) {
                let {code, msg} = data;
                if (code === 200) {
                    alert(msg)
                    location.href = '#personal'
                } else {
                    alert(msg)
                }
            }
        })
    })
})